/*
 * Wazuh Vulnerability scanner
 * Copyright (C) 2015, Wazuh Inc.
 * March 25, 2023.
 *
 * This program is free software; you can redistribute it
 * and/or modify it under the terms of the GNU General Public
 * License (version 2) as published by the FSF - Free Software
 * Foundation.
 */

#ifndef _VULNERABILITY_SCANNER_HPP
#define _VULNERABILITY_SCANNER_HPP

#if __GNUC__ >= 4
#define EXPORTED __attribute__((visibility("default")))
#else
#define EXPORTED
#endif

#include "logging_helper.h"
#include "singleton.hpp"
#include "vulnerabilityScannerDefs.hpp"
#include <external/nlohmann/json.hpp>
#include <functional>
#include <memory>
#include <string>
#include <vector>

constexpr auto HOTFIXES_APPLICATIONS_COLUMN {"hotfixes_applications"};
constexpr auto REMEDIATIONS_COLUMN {"remediations"};
constexpr auto TRANSLATIONS_COLUMN {"translation"};
constexpr auto DESCRIPTIONS_COLUMN {"descriptions"};
constexpr auto VENDOR_MAP_COLUMN {"vendor_map"};
constexpr auto OS_CPE_RULES_COLUMN {"oscpe_rules"};
constexpr auto CNA_MAPPING_COLUMN {"cna_mapping"};
constexpr auto LOCALFILE_MQ {"1"};

/**
 * @brief VulnerabilityScanner class.
 *
 */
class EXPORTED VulnerabilityScanner final : public Singleton<VulnerabilityScanner>
{
public:
    /**
     * @brief Starts vulnerability scanner.
     *
     * @param logFunction Log function to be used.
     * @param configuration Scanner configuration.
     * @param noWaitToStop If true, the scanner will not wait to stop if any process is running.
     * @param reloadGlobalMapsStartup If true, the vendor map and os cpe map will be reloaded at startup of the database
     * @param initContentUpdater If true, the content updater will be initialized.
     * feed manager.
     */
    void start(const std::function<void(const int,
                                        const std::string&,
                                        const std::string&,
                                        const int,
                                        const std::string&,
                                        const std::string&,
                                        va_list)>& logFunction,
               const nlohmann::json& configuration,
               bool noWaitToStop = true,
               bool reloadGlobalMapsStartup = true,
               bool initContentUpdater = true);
    /**
     * @brief Stops vulnerability scanner.
     *
     */
    void stop();
};

#endif // _VULNERABILITY_SCANNER_HPP
